package com.cskaoyan;

import com.cskaoyan.utils.JDBCUtils;
import com.mysql.jdbc.Driver;

import java.sql.*;

/**
 * 创建日期: 2022/03/21 17:43
 *
 * @author ciggar
 * 查询
 */
public class QueryJDBC2 {



    public static void main(String[] args) throws SQLException {

        Connection connection = JDBCUtils.getConnection();
        // 3. 获取statement对象
        Statement statement = connection.createStatement();

        // 4. 执行SQL语句
        ResultSet resultSet = statement.executeQuery("select * from city");


        while (resultSet.next()) {

            String name = resultSet.getString("name");
            int id = resultSet.getInt("id");
            int pId = resultSet.getInt("p_id");
            System.out.println("name:"+ name + ",id:" + id + ",pId:" + pId);
        }


        JDBCUtils.close(resultSet,statement,connection);


    }


}
